#include <iostream>
#include <vector>
#include <assert.h>
#include <string>

using namespace std;

#include "RBTree.h"
#include "Set.h"
#include "Map.h"

//void TestRBTree1()
//{
//	// 测试双旋平衡因子调节
//	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14, 0,5,30,25,20,4,13,30,28,27 };  
//	//int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
//	RBTree<int, int> t1;
//	for (auto e : a)
//	{
//		t1.insert(make_pair(e, e));
//	}
//
//	t1.InOrder();
//	cout << "IsBalance:" << t1.isRBTree() << endl;
//}
//
//void TestRBTree2()
//{
//	size_t N = 1000;
//	srand(time(0));
//	RBTree<int, int> t1;
//	for (size_t i = 0; i < N; ++i)
//	{
//		int x = rand();
//		cout << "Insert:" << x << ":" << i << endl;
//		t1.insert(make_pair(x, i));
//		cout << "IsBalance:" << t1.isRBTree() << endl;
//	}
//	t1.InOrder();
//	cout << "IsBalance:" << t1.isRBTree() << endl;
//}

void testMyset()
{
    my_set::set<int> s1;
    s1.insert(10);
    s1.insert(5);
    s1.insert(1);
    s1.insert(6);
    s1.insert(8);
    s1.insert(2);
    s1.insert(4);
    s1.insert(9);
    s1.insert(7);
    my_set::set<int>::iterator it1 = s1.begin();
    while (it1 != s1.end())
    {
        cout << *it1 << ' ';
        ++ it1;
    }
    cout << endl;
}

void testMymap()
{
    my_map::map<string, int> m1;

    string s[] = { "苹果","香蕉","苹果","西瓜","香蕉","草莓" };
    for (auto& e : s)
    {
        m1[e] ++ ;
    }

    my_map::map<string, int>::iterator it = m1.begin();
    while (it != m1.end())
    {
        cout << it->first << ':' << it->second << endl;
        ++ it;
    }
    cout << endl;
}

int main()
{
    testMyset();
    cout << endl;

    testMymap();
    cout << endl;

    return 0;
}
